'use strict';

/**
 * @param {number[]} nums
 * @param {number} k
 * @return {void} Do not return anything, modify nums in-place instead.
 */
var rotate = function (nums, k) {
  if (nums.length === 1) return;

  k = k % nums.length;
  const temp = nums.splice(nums.length - k, k);

  nums.unshift(...temp);
  console.log(nums);
};

// Example usage:
const nums = [1, 2, 3, 4, 5, 6, 7];
rotate(nums, 3); // [5, 6, 7, 1, 2, 3, 4]
